using System.Collections.Generic;
using ProtoModels;
using UnityEngine;

public class RemoteStats : SkillProvider
{
	private List<SkillLevel> skills;

	private float normalizedVisualSpeed;

	private StoreItemAdapter.RacketAdapter racket;

	public RemoteStats(List<SkillLevel> skills, float normalizedVisualSpeed, string racketId)
	{
		this.skills = skills;
		this.normalizedVisualSpeed = normalizedVisualSpeed;
		racket = new StoreItemAdapter.StoreRacket(StoreItemsConfig.instance.FindItemWithId(racketId));
	}

	public override float DoGetSkillValue(int skillTypeIndex)
	{
		if (skills == null)
		{
			skills = new List<SkillLevel>();
		}
		switch (skillTypeIndex)
		{
		case 3:
			return normalizedVisualSpeed;
		case 2:
			Debug.Log("Racket visual speed " + racket.normalizedVisualSpeed);
			return racket.normalizedVisualSpeed;
		default:
		{
			SkillLevel orAddSkill = GetOrAddSkill(skillTypeIndex);
			LevelSystem.LevelInfo skillLevelInfo = LevelSystem.instance.GetSkillLevelInfo((PlayerStatsManager.SkillType)skillTypeIndex, orAddSkill.level);
			return (float)skillLevelInfo.levelIndex + skillLevelInfo.subLevelProgress;
		}
		}
	}

	private SkillLevel GetOrAddSkill(int skillTypeIndex)
	{
		foreach (SkillLevel skill in skills)
		{
			if (skill.skillTypeInt == skillTypeIndex)
			{
				return skill;
			}
		}
		SkillLevel skillLevel = new SkillLevel();
		skillLevel.skillTypeInt = skillTypeIndex;
		skillLevel.level = 0f;
		return skillLevel;
	}
}
